package demo;

import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

public class Demo13 {
    public static void main(String[] args) {
        ConcurrentHashMap<String, String> map1 = new ConcurrentHashMap<>();
        ConcurrentHashMap<String, String> map2 = new ConcurrentHashMap<>();
        ConcurrentHashMap<String, String> map3 = new ConcurrentHashMap<>();
        String k="";
        for(int i = 0; i<100000 ; i++){
            String key = UUID.randomUUID().toString();
            String value = "value"+i;
            if (i == 0) k = key;
            if (i<1000) map1.put(key,value);
            if (i<10000) map2.put(key,value);
            map3.put(key,value);
        }
        //得到 一个 k, 和3个map集合 map1 map2 map3
        long t1 = System.nanoTime();
        String v1 = map1.get(k);
        long t2 = System.nanoTime();
        String v2 = map2.get(k);
        long t3 = System.nanoTime();
        String v3 = map3.get(k);
        long t4 = System.nanoTime();
        //输出结果
        System.out.println("key:"+k);
        System.out.println("map1 get(k):"+v1+"耗时: "+(t2-t1));
        System.out.println("map2 get(k):"+v2+"耗时: "+(t3-t2));
        System.out.println("map3 get(k):"+v3+"耗时: "+(t4-t3));
    }
}
